package com.tudouji.project.weigh.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.weigh.domain.WeightInterfaceParam;
import com.tudouji.project.weigh.service.IWeightInterfaceParamService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 过磅参数接口Controller
 * 
 * @author tudouji
 * @date 2023-03-22
 */
@RestController
@RequestMapping("/weigh/param")
public class WeightInterfaceParamController extends BaseController
{
    @Autowired
    private IWeightInterfaceParamService weightInterfaceParamService;

    /**
     * 查询过磅参数接口列表
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:list')")
    @GetMapping("/list")
    public TableDataInfo list(WeightInterfaceParam weightInterfaceParam)
    {
        startPage();
        List<WeightInterfaceParam> list = weightInterfaceParamService.selectWeightInterfaceParamList(weightInterfaceParam);
        return getDataTable(list);
    }

    /**
     * 导出过磅参数接口列表
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:export')")
    @Log(title = "过磅参数接口", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WeightInterfaceParam weightInterfaceParam)
    {
        List<WeightInterfaceParam> list = weightInterfaceParamService.selectWeightInterfaceParamList(weightInterfaceParam);
        ExcelUtil<WeightInterfaceParam> util = new ExcelUtil<WeightInterfaceParam>(WeightInterfaceParam.class);
        return util.exportExcel(list, "param");
    }

    /**
     * 获取过磅参数接口详细信息
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(weightInterfaceParamService.selectWeightInterfaceParamById(id));
    }

    /**
     * 新增过磅参数接口
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:add')")
    @Log(title = "过磅参数接口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WeightInterfaceParam weightInterfaceParam)
    {
        return toAjax(weightInterfaceParamService.insertWeightInterfaceParam(weightInterfaceParam));
    }

    /**
     * 修改过磅参数接口
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:edit')")
    @Log(title = "过磅参数接口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WeightInterfaceParam weightInterfaceParam)
    {
        return toAjax(weightInterfaceParamService.updateWeightInterfaceParam(weightInterfaceParam));
    }

    /**
     * 删除过磅参数接口
     */
    @PreAuthorize("@ss.hasPermi('weigh:param:remove')")
    @Log(title = "过磅参数接口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(weightInterfaceParamService.deleteWeightInterfaceParamByIds(ids));
    }
}
